$(document).ready(function() {
            $("#DdlQue").change(function() {
        var Txt = $(this).val();
        if (Txt == '--- Select One ---') {
            $("#LblQue").text("Please Select a Security Question !");
            $("#ImgQue").hide();
        }
        else { $("#LblQue").text(""); $("#ImgQue").show(); }
    });
    
    $("#DdlLoc").change(function() {
        var Txt = $(this).val();
        if (Txt == '--- Select One ---') {
            $("#LblLoc").text("Please Select a Nearest Location to Your Area !");
            $("#ImgLoc").hide();
        }
        else { $("#LblLoc").text(""); $("#ImgLoc").show(); }
    });
    
    $("#TxtFName").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblFName").text("Required !"); $("#ImgFName").hide(); }
        else if (Check(Txt)) { $("#LblFName").text("Special Characters not allowed!"); $("#ImgFName").hide(); }
        else { $("#ImgFName").show(); $("#LblFName").text(""); }
    });
    
    $("#TxtLName").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblLName").text("Required !"); $("#ImgLName").hide(); }
        else if (Check(Txt)) { $("#LblLName").text("Special Characters not allowed!"); $("#ImgLName").hide(); }
        else { $("#ImgLName").show(); $("#LblLName").text(""); }
    });
    
    $("#TxtMob1").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblMob1").text("Required !"); $("#ImgMob1").hide(); }
        else if (CheckMob(Txt)) { $("#LblMob1").text("Requires 10 digits Valid Mobile No. !"); $("#ImgMob1").hide(); }
        else { $("#ImgMob1").show(); $("#LblMob1").text(""); }
    });
    
    $("#TxtPWD").change(function() {
        Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblPWD").text("Required !"); $("#ImgPWD").hide(); }
        else if (!(Txt.length > 5)) {
            $("#LblPWD").text("Minimum password length is 6 characters"); $("#ImgPWD").hide();
        }
        else { $("#LblPWD").text(""); $("#ImgPWD").show(); }
    });
    
    $("#TxtRePWD").change(function() {
        var Txt = $(this).val();
        var Txt2 = $("#TxtPWD").val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblRePWD").text("Required !"); $("#ImgRePWD").hide(); }
        else if (!(Txt.length > 5)) {
            $("#LblRePWD").text("Minimum password length is 6 characters"); $("#ImgRePWD").hide();
        }
        else if (!(Txt === Txt2)) {
            $("#LblRePWD").text("Both Passwords not matched !");
            $("#ImgRePWD").hide();
        }
        else { $("#LblRePWD").text(""); $("#ImgRePWD").show(); }
    });

    $("#TxtEmail").change(function() {
        var Txt = $(this).val();
        var atpos = Txt.indexOf("@");
        var dotpos = Txt.lastIndexOf(".");
        if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= Txt.length) {
            $("#LblEmail").text("Not a Valid Email id");
            $("#ImgEmail").hide();
        }
        else {
            $.ajax({
                type: "POST",
                url: "Class/ASE.asmx/ChkEmail",
                data: "{Txt:'" + Txt + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                error: OnError
            });
        }
    });

        $("#TxtAns").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblAns").text("Required !"); $("#ImgAns").hide(); }
        else if (Check(Txt)) { $("#LblAns").text("Special Characters not allowed!"); $("#ImgAns").hide(); }
        else { $("#ImgAns").show(); $("#LblAns").text(""); }
    });
    
    $("#TxtAddL1").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblAddL1").text("Required !"); $("#ImgAddL1").hide(); }
        else if (Check(Txt)) { $("#LblAddL1").text("Special Characters not allowed!"); $("#ImgAddL1").hide(); }
        else { $("#ImgAddL1").show(); $("#LblAddL1").text(""); }
    });
    
    
    
    
    
    
    
    
    
    $("#TxtArea").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblArea").text("Required !"); $("#ImgArea").hide(); }
        else if (Check(Txt)) { $("#LblArea").text("Special Characters not allowed!"); $("#ImgArea").hide(); }
        else { $("#ImgArea").show(); $("#LblArea").text(""); }
    });
    
    $("#TxtLandMark").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblLandMark").text("Required !"); $("#ImgLandMark").hide(); }
        else if (Check(Txt)) { $("#LblLandMark").text("Special Characters not allowed!"); $("#ImgLandMark").hide(); }
        else { $("#ImgLandMark").show(); $("#LblLandMark").text(""); }
    });
    
    $("#TxtPinCode").change(function() {
        var Txt = $(this).val();
        if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblPinCode").text("Required !"); $("#ImgPinCode").hide(); }
        else if (!(/^[0-9]\d{5}$/.test(Txt))) { $("#LblPinCode").text("Requires 6 digit Pin Code !"); $("#ImgPinCode").hide(); }
        else { $("#LblPinCode").text(""); $("#ImgPinCode").show(); }
    });
    
    $("#TxtStreet").change(function() {
        var Txt = $(this).val();
        if (!Txt == null || !Txt == "" || (Trim(Txt).length > 0)) {
            if (Check(Txt)) {
                $("#LblStreet").text("Special Characters not allowed!");
                $("#ImgStreet").hide();
            }
            else { $("#LblStreet").text(""); $("#ImgStreet").show(); }
        }
    });
    
      $("#TxtRef").change(function() {
      var Txt = $(this).val();
         var M = $("#TxtMob1").val();
    if (CheckMob(Txt) && Trim(Txt).length > 0) {
        $("#LblRef").text("Requires 10 digits Valid Mobile No."); Result = false;
        $("#ImgRef").hide();
    }
    else if (Txt === M && Trim(Txt).length > 0) {
         $("#LblRef").text("Primary mobile no. and referred  by mobile no. can't be the same !"); Result = false;
         $("#ImgRef").hide();
    }
     else if (Trim(Txt).length ==10) {
          $.ajax({
                type: "POST",
                url: "Class/ASE.asmx/ChkMob1",
                data: "{Txt:'" + Txt + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess1,
                error: OnError1
            });
            }
        else{
      $("#LblRef").text("");
      }
      
      });
      
});
//-------------------------------------------------------------------
function VForm() {
    var Result = new Boolean(true);
    var Txt = $("#TxtFName").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblFName").text("Required !"); Result = false; }
    else if (Check(Txt)) { $("#LblFName").css({ "visibility": "visible" }); $("#LblFName").text("Special Characters not allowed!"); Result = false; }

    Txt = $("#TxtLName").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblLName").text("Required !"); Result = false; }
    else if (Check(Txt)) { $("#LblLName").css({ "visibility": "visible" }); $("#LblLName").text("Special Characters not allowed!"); Result = false; }
    
    Txt = $("#TxtEmail").val();
    var atpos = Txt.indexOf("@");
    var dotpos = Txt.lastIndexOf(".");
    if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= Txt.length) {
        $("#LblEmail").text("Not a Valid Email ID !");
        Result = false;
    }
    
    Txt = $("#TxtPWD").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblPWD").text("Required !");Result = false; }
    else if (!(Trim(Txt).length > 5)) { $("#LblPWD").css({ "visibility": "visible" }); $("#LblPWD").text("Minimum password length is 6 characters"); Result = false; }
    
    Txt = $("#TxtRePWD").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblRePWD").text("Required !"); Result = false; }
    
    var PWD = $("#TxtPWD").val();
    var RePWD = $("#TxtRePWD").val();
    if (!(PWD === RePWD) && (Trim(PWD).length > 5)) { $("#LblRePWD").text("Both Passwords not matched !"); Result = false; }
    
    Txt = $("#TxtMob1").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblMob1").text("Required !"); Result = false; }
    else if (CheckMob(Txt)) { $("#LblMob1").css({ "visibility": "visible" }).text("Requires 10 digits Valid Mobile No."); Result = false; }
    
    
  
    Txt = $("#TxtPinCode").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblPinCode").text("Required"); Result = false; }
    else if (!(/^[0-9]\d{5}$/.test(Txt))) { $("#LblPinCode").text("Enter valid 6 digits Pin Code !"); Result = false; }
    
    Txt = $("#TxtStreet").val();
    if (!Txt == null || !Txt == "" || (Trim(Txt).length > 0)) {
        if (Check(Txt)) { $("#LblStreet").text("Required");Result = false; }
    }
    
     Txt = $("#TxtArea").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblArea").text("Required");Result = false; }
    else if (Check(Txt)) { $("#LblArea").text("Special Characters not allowed!"); Result = false; }
    
      Txt = $("#TxtLandMark").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblLandMark").text("Required !"); Result = false; }
    else if (Check(Txt)) { $("#LblLandMark").text("Special Characters not allowed!"); Result = false; }
    
          Txt = $("#TxtAns").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblAns").text("Required !"); Result = false; }
    else if (Check(Txt)) { $("#LblAns").text("Special Characters not allowed!"); Result = false; }
       
       
       
    Txt = $("#DdlLoc").val();
    if (Txt == "--- Select One ---") {
        $("#LblLoc").text("Required");Result = false;
    }
     Txt = $("#DdlQue").val();
    if (Txt == "--- Select One ---") {
        $("#LblQue").text("Required");Result = false;
    }
   
    Txt = $("#TxtAddL1").val();
    if (Txt == null || Txt == "" || !(Trim(Txt).length > 0)) { $("#LblAddL1").text("Required !"); Result = false; }
    else if (Check(Txt)) { $("#LblAddL1").text("Special Characters not allowed!"); Result = false; }
   
   
   
   
   
   
    
        Txt = $("#TxtRef").val();
    var M = $("#TxtMob1").val();
    if (CheckMob(Txt) && Trim(Txt).length > 0) {
        $("#LblRef").text("Requires 10 digits Valid Mobile No."); Result = false;
    }
    else if (Txt === M && Trim(Txt).length > 0) {
         $("#LblRef").text("Primary mobile no. and referred  by mobile can't be the same !"); Result = false;
    }
        else{
      $("#LblRef").text("");
      }
       return Result;
  }

function Trim(Str) { return Str.replace(/^\s+|\s+$/g, ""); }
function CheckMob(Txt) { if (/^[789]\d{9}$/.test(Txt)) { return false; } else { return true;} }
function Check(Txt) { 
if (/^[-\sa-zA-Z0-9,./]+$/.test(Txt)) {
 return false;
 }
  else {
   return true;
   } }
function CheckMob(Txt) { if (/^[789]\d{9}$/.test(Txt)) { return false } else { return true } }
function OnSuccess(data, status) {
    if (data.d == 0) {
        $("#LblEmail").text("Email id already used !");
        $("#ImgEmail").hide();
    }
    else {
        $("#ImgEmail").show();
               $("#LblEmail").text("");
    }
}
function OnSuccess1(data, status) {
    if (data.d == 1) {
        $("#LblRef").text("This Mobile no. is not registered with us !");
        $("#ImgRef").hide();
    }
    else {
      $("#LblRef").text("");
      $("#ImgRef").show();
    }
}
  function OnError(request, status, error) { alert("You got some errors"); }
  function OnError1(request, status, error) { alert("You got some errors gbhgf"); }